<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>组织生活详情</title>
		<meta name="decorator" content="default"/>
				
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/css/bootstrap.css">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/css/base.css">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/css/common.css">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/css/layout.css">
	<script src="<%=request.getContextPath()%>/static/js/jquery-1.10.2.js" type="text/javascript" charset="utf-8"></script>
	<script src="<%=request.getContextPath()%>/static/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="<%=request.getContextPath()%>/static/layer/layer.js"></script>
	
		<style type="text/css">
			.e-form input{
				padding: 5px 0 !important;
			}
		</style>
<script type="text/javascript">
		$(document).ready(function() {			
			
			 //删除方法
	        $('.shanc').click(function (){
	          if($('.lkj').length<=1){
	            return ;
	          }else {
	             $(this).parents(".lkj").remove();
	             checkRowNumber();
	          }		        
	          })
			 //删除方法
			        $('.libts').click(function (){
			          if($('.dyjs').length<=1){
			            return 
			          }else {
			             $(this).parents(".dyjs").remove();
			             dycheckRowNumber();
			          }			        
			          })	    
			
			
			var personid="";
			var personName="";
			$('#_card_child').click(function (){
				
				var check=true;
			    personid=$("#pid").val();	
			    $.ajax({  
			        url: "${ctx}/partycard/partycard/getPersonById/"+personid,  
			        type: "get",  
			        dataType: "json",  
			        async: false,//同步  
			        success: function(text){  
			        	if(text.type == "sucess"){
			        		personid=text.partycard.personid;
			        		personName=text.partycard.personname;
								if(personName == ''){
									top.$("#_card_error1").click();
									check=false;					
								}	
								$("#personInfo").find("tr").each(function(){		    			
					    			var personId1=$(this).children("td").eq(1).children("input").eq(0).val();
					       			if(personid==personId1){
					    				//alert("当前党员已签到，请重新选择！");
					    				top.$("#_card_error").click();
					    				check=false;
					    				
					    			}
					    		});		    
				if(check){
					
					  var date = new Date();
					    var seperator1 = "-";
					    var seperator2 = ":";
					    var year = date.getFullYear();
					    var month = date.getMonth() + 1;
					    var strDate = date.getDate();
					    if (month >= 1 && month <= 9) {
					        month = "0" + month;
					    }
					    if (strDate >= 0 && strDate <= 9) {
					        strDate = "0" + strDate;
					    }
					    var currentdate = date.getHours() + seperator2 + date.getMinutes();
					
					
					var sqscore=0;
					var shcore=0;
					var divs = $("#personS").find("div[id^=dyjs]");	    	    
		    		$(divs).each(function(j, divs) {		      			
		    			 score=$("#dyscoreNumber"+j).val();
		    			 defaultScore=$("#dyfz"+j).val();
		    			 sqscore=sqscore+score*1;
		    			 shcore=shcore+defaultScore*1;
		    		});		
		    		var itemSeq = 1 ;
					var trs = $("#personInfo").find("tr");
					var xuhao = trs.length;
					itemSeq++;
					
					$("#personInfo").append("<tr class='personInfo' id='"
									+ (xuhao + 1)
									+ "'>"
									+ "<td><span style='color:black'>"
									+ (xuhao + 1)
									+ "</span></td>"
									+ "<td>"+personName+"<input type='hidden' id='personId' value="+personid+" ></input></td>"
									+ "<td>男</td>"
									+ "<td>刷卡录入<input type='hidden' id='signMode' value='1' ></input></td>"
									+ "<td>"+currentdate+"</td>"
									+ "<td style='text-align: center;'><button onclick='delPerson(this)' class='btn' data-toggle='modal' style='background: red; color: #FFF;'  data-target='#modal-del'>删除</button></td>"
									+ "</tr>");
								top.$("#_card_sucess").click();
							    }	
							} else {
								top.$("#_card_error2").click();
								check=false;	
							}	
			        }  
			    });  
				$("#pid").val("");
				personid=="";
				
			});			
			//页面加载获取组织积分内容			
			var partyscoreid=$('#partyscoreid0').val();			
			function queryPartyAssessmentInfo(partyscoreid,size){
				if(partyscoreid != null && partyscoreid != ''){					
					 $.ajax({  
					        url: "${ctx}/life/organizeLifeQd/queryPartyAssessmentInfo/"+partyscoreid,  
					        type: "get",  
					        dataType: "json",  
					        async: false,//同步  
					        success: function(text){  
					        	if(text.scoreMode=='1'){
					        		$("#scoreModeText"+size).val("固定");
					        		$("#dzzscore"+size).attr("readonly","readonly");
					        	}else{
					        		$("#scoreModeText"+size).val("自设");
					        		$("#dzzscore"+size).removeAttr("readonly");
					        	}
					        	//$("#scoreMode"+size).val(text.scoreMode); 					        	
					        	$("#scoreNumber"+size).val(text.scoreNumber); 
					        	$("#dzzscore"+size).val(text.scoreNumber); 					        	
					        	if(text.type=='1'){
					        		$("#typeText"+size).val("加分"); 
					        	}else{
					        		$("#typeText"+size).val("减分"); 
					        	}
					        	$("#dzztype"+size).val(text.type); 
					        	//$("#type"+size).val(text.type); 					        	
					        	$("#upperLimitScore"+size).val(text.upperLimitScore);
					        	$("#dzzsqcs"+size).val(text.applyCount);
					        }  
					    });  
				}
			}	
			//调用获取组织积分明细方法
			var divs = $("#ceons").find("div[id^=lkj]");	    	    
	    		$(divs).each(function(j, divs) {
	    			var partyAssessmentInfoId=$("#partyscoreid"+j).val();
	    			queryPartyAssessmentInfo(partyAssessmentInfoId,j)
	    		});
						
			//点击增加按钮，增加一个div并且重新调用获取组织积分明细方法
		      $('#lbtns').click(function (){
		    	  var size=$('.lkj').length;
		    	  var hml1="<div id='lkj"+size+"' class='lkj'><div class='e-form pl15 form-item w-100per cler pt10 pb10'>"+
					"	<div class='col-md-1 tr'><span class='form-item-name w-5xl lh32'>积分内容</span></div><div class='col-md-9'>"+
					"	<select id='partyscoreid"+size+"' onchange='change(this.options[this.options.selectedIndex].value,"+size+");' class='form-item-input w-100xl'>"+
					"	<c:forEach var='e' items='${partyAssessmentInfoList}' varStatus='i'>"+															
					"	<option value='${e.id }'>${e.integralContent }</option>"+																
					"	</c:forEach></select></div></div><div class='form-item e-form w-100per pl15 cler divGroup'>"+
					"	<div class='col-md-1 tr'><span class='form-item-name w-5xl lh32'>赋分方式</span></div>"+
					"	<div class='col-md-1'><input id='scoreModeText"+size+"' type='text'  readonly='readonly' style='width:50px'></div>"+											
					"	<div class='col-md-2 tr'><span class='form-item-name w-5xl lh32'>上限分值/次</span></div><div class='col-md-1 '>"+
					"   <input id='scoreNumber"+size+"' type='text' readonly='readonly' style='width:50px'></div>"+
					"	<div class='col-md-2 tr'><span class='form-item-name w-5xl lh32'>申请积分<span style='color: red;font-size:50%;' >★</span></span></div><div class='col-md-1 '>"+
					"	<input id='dzzscore"+size+"' type='text' onkeyup='checknum(this);' readonly='readonly' style='width:50px'></div></div><div class='form-item e-form w-100per pl15 cler divGroup'>"+
					"	<div class='col-md-1 tr'><span class='form-item-name w-5xl lh32'>类型 </span></div><div class='col-md-1 '>"+
					"	<input id='typeText"+size+"' type='text' readonly='readonly' style='width:50px'><input type='hidden' id='dzztype"+size+"'></div>"+
					"	<div class='col-md-2 tr'><span class='form-item-name w-5xl lh32'>上限分值 </span></div>"+
					"	<div class='col-md-1 '><input id='upperLimitScore"+size+"' type='text' readonly='readonly' style='width:50px'></div>"+
					"	<div class='col-md-2 tr'><span class='form-item-name w-5xl lh32'>已申请次数</span></div>"+
					"	<div class='col-md-1 '><input id='dzzsqcs"+size+"' type='text' readonly='readonly' style='width:50px'></div><div class='col-md-2 tr'>"+
					"	<div class='btn-group'><button class='btn shanc' data-toggle='modal' style='background: red; color: #FFF;'  data-target='#modal-del'>删除</button></div></div></div>"+
					"<hr style='height:1px;border:none;border-top:1px  #555555;' /></div>"
		        $('#ceons').append(hml1);
		        var partyscoreid=$('#partyscoreid'+size).val();
		        queryPartyAssessmentInfo(partyscoreid,size);
		        		        
		      //删除方法
		        $('.shanc').click(function (){
		          if($('.lkj').length<=1){
		            return ;
		          }else {
		             $(this).parents(".lkj").remove();
		             checkRowNumber();
		          }		        
		          })
		      })
		      
		//删除一个div后更新div的序号
	      function checkRowNumber() {
	    	    //根据div的id模糊查询出div的总数循环遍历
	    		var divs = $("#ceons").find("div[id^=lkj]");	    	    
	    		$(divs).each(function(j, divs) {
	    			$(this).prop("id", "lkj" + (j));
	    			$("#lkj"+j).find("select[id^=partyscoreid]").prop("id", "partyscoreid" + (j));	//积分id    			                            
	    			$("#lkj"+j).find("input[id^=scoreModeText]").prop("id", "scoreModeText" + (j));	//赋分方式
	    			$("#lkj"+j).find("input[id^=typeText]").prop("id", "typeText" + (j));
	    			$("#lkj"+j).find("input[id^=dzztype]").prop("id", "dzztype" + (j));
	    			$("#lkj"+j).find("input[id^=dzzscore]").prop("id", "dzzscore" + (j));//分值
	    			$("#lkj"+j).find("input[id^=scoreNumber]").prop("id", "scoreNumber" + (j));//分数
	    			$("#lkj"+j).find("input[id^=upperLimitScore]").prop("id", "upperLimitScore" + (j));//上限分数
	    			$("#lkj"+j).find("input[id^=sqcs]").prop("id", "sqcs" + (j));//已申请次数    			
	    			$("#lkj"+j).find("select[id^=partyscoreid]").attr("onchange","change(this.options[this.options.selectedIndex].value,"+j+")");	    			
	    		});
	    	}		      
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

		    //页面加载获取党员积分内容			
				var personscoreid=$('#personscoreid0').val();
				function queryPersonAssessmentInfo(personscoreid,size){
					if(personscoreid != null && personscoreid != ''){					
						 $.ajax({  
						        url: "${ctx}/life/organizeLifeQd/queryPersonAssessmentInfo/"+personscoreid,  
						        type: "get",  
						        dataType: "json",  
						        async: false,//同步  
						        success: function(text){  
						        	if(text.sourceType=='1'){
						        		$("#dyscoreModeText"+size).val("固定");
						        		$("#dyfz"+size).attr("readonly","readonly");
						        	}else{
						        		$("#dyscoreModeText"+size).val("自设");
						        		$("#dyfz"+size).removeAttr("readonly");
						        	}
						        	$("#dyscoreMode"+size).val(text.sourceType); 			//分值方式：固定，自设		        	
						        	$("#dyscoreNumber"+size).val(text.upperCount); //分/次
						        	$("#dyfz"+size).val(text.upperCount); 					        	
						        	if(text.type=='1'){
						        		$("#dytyText"+size).val("加分"); 
						        	}else{
						        		$("#dytyText"+size).val("减分"); 
						        	}
						        	$("#dytype"+size).val(text.type); 					        	
						        	$("#dyupperLimitScore"+size).val(text.upperScore);
						        	$("#dysqcs"+size).val(text.applyCount);
						        }  
						    });  
					}
				}
				
				//调用获取组织积分明细方法
				var divs = $("#personS").find("div[id^=dyjs]");	    	    
		    		$(divs).each(function(j, divs) {
		    			var personAssessmentInfoId=$("#personscoreid"+j).val();
		    			queryPersonAssessmentInfo(personAssessmentInfoId,j);
		    			
		    		});								
			
				$('#libt').click(function (){
			    	  var size=$('.dyjs').length;
			    	  var hml2="<div id='dyjs"+size+"' class='dyjs'><div class='e-form pl15 form-item w-100per cler pt10 pb10'>"+
						"	<div class='col-md-1 tr'><span class='form-item-name w-5xl lh32'>积分内容</span></div><div class='col-md-9'>"+
						"	<select id='personscoreid"+size+"' onchange='dychange(this.options[this.options.selectedIndex].value,"+size+");' class='form-item-input w-100xl'>"+
						"	<c:forEach var='e' items='${personAssessmentInfoList}' varStatus='i'>"+															
						"	<option value='${e.id }'>${e.title }</option>"+																
						"	</c:forEach></select></div></div><div class='form-item e-form w-100per pl15 cler divGroup'>"+
						"	<div class='col-md-1 tr'><span class='form-item-name w-5xl lh32'>赋分方式</span></div>"+
						"	<div class='col-md-1'><input id='dyscoreModeText"+size+"' type='text'  readonly='readonly' style='width:50px'></div>"+											
						"	<div class='col-md-2 tr'><span class='form-item-name w-5xl lh32'>上限分值/次</span></div><div class='col-md-1 '>"+
						"   <input id='dyscoreNumber"+size+"' type='text'  readonly='readonly' style='width:50px'></div>"+
						"	<div class='col-md-2 tr'><span class='form-item-name w-5xl lh32'>申请积分<span style='color: red;font-size:50%;' >★</span></span></div><div class='col-md-1 '>"+
						"	<input id='dyfz"+size+"' type='text' onkeyup='checknum(this);' readonly='readonly' style='width:50px'></div></div><div class='form-item e-form w-100per pl15 cler divGroup'>"+
						"	<div class='col-md-1 tr'><span class='form-item-name w-5xl lh32'>类型 </span></div><div class='col-md-1 '>"+
						"	<input id='dytyText"+size+"' type='text' readonly='readonly' style='width:50px'><input type='hidden' id='dytype"+size+"'></div>"+
						"	<div class='col-md-2 tr'><span class='form-item-name w-5xl lh32'>上限分值 </span></div>"+
						"	<div class='col-md-1 '><input id='dyupperLimitScore"+size+"' type='text' readonly='readonly' style='width:50px'></div>"+
						"	<div class='col-md-2 tr'><span class='form-item-name w-5xl lh32'>已申请次数</span></div>"+
						"	<div class='col-md-1 '><input id='dysqcs"+size+"' type='text' readonly='readonly' style='width:50px'></div><div class='col-md-2 tr'>"+
						"	<div class='btn-group'><button class='btn libts' data-toggle='modal' style='background: red; color: #FFF;'  data-target='#modal-del'>删除</button></div></div></div>"+
						"<hr style='height:1px;border:none;border-top:1px  #555555;' /></div>"
			        $('#personS').append(hml2);
			        var personscoreid=$('#personscoreid'+size).val();
			        queryPersonAssessmentInfo(personscoreid,size);
			      //删除方法
			        $('.libts').click(function (){
			          if($('.dyjs').length<=1){
			            return 
			          }else {
			             $(this).parents(".dyjs").remove();
			             dycheckRowNumber();
			          }			        
			          })	        
					
			      })		
			      
			      function dycheckRowNumber() {
			    	    //根据div的id模糊查询出div的总数循环遍历
			    		var divs = $("#personS").find("div[id^=dyjs]");	    	    
			    		$(divs).each(function(j, divs) {
			    			$(this).prop("id", "dyjs" + (j));
			    			                              
			    			$("#dyjs"+j).find("select[id^=personscoreid]").prop("id", "personscoreid" + (j));	//积分id
			    			$("#dyjs"+j).find("input[id^=dyscoreModeText]").prop("id", "dyscoreModeText" + (j));	//赋分方式
			    			$("#dyjs"+j).find("input[id^=dytype]").prop("id", "dytype" + (j));//类型 加分减分
			    			$("#dyjs"+j).find("input[id^=dytyText]").prop("id", "dytyText" + (j));
			    			$("#dyjs"+j).find("input[id^=dyfz]").prop("id", "dyfz" + (j));//分值
			    			$("#dyjs"+j).find("input[id^=dyscoreNumber]").prop("id", "dyscoreNumber" + (j));//分数
			    			$("#dyjs"+j).find("input[id^=dyupperLimitScore]").prop("id", "dyupperLimitScore" + (j));//上限分数
			    			$("#dyjs"+j).find("input[id^=dysqcs]").prop("id", "dysqcs" + (j));//已申请次数
			    		});
			    	}		    
			    //手工录入事件  
				$('#sgAdd').click(function (){
					
					var html ="";
					$.ajax({
						url : "${ctx}/life/organizeLifeJh/getPersonByOrgid",
						type : "get",
						dataType : "json",
						async : false,//同步  
						success : function(text) {
							html +=  "<div style='text-align:left'>"
							+"<input id='xgBtn1' onclick='xg()' class='btn libts' style='background: red; color: #FFF;' type='button' value='确认'/></div>"
							+"<div class='tab-pane' style='padding: 20px 40px;'><table class=''>"
							for (var i = 0; i < text.length; i++) {
								
								var sex="";
								if(text[i].sex=='1'){
									sex="男";
								}else if(text[i].sex=='2'){
									sex="女";									
								}else{
									sex="男";
								}
								html+="<tr id='"+ (i + 1)+ "'>"
												+ "<td style='width:30px'><input type='radio' class='sds' id='radioPersonId' name='radioPersonId' value="+text[i].userId+"></td>"
												+ "<td style='width:100px'><span style='color:black'>"+text[i].userName+"</span></td>"
												+ "<td style='width:100px'><span style='color:black'>"+sex+"</span></td>"
												+ "</tr>";
												}
							html+="</table></div>"
							
						}
					});

					layer.open({
								type : 1,
								skin : 'layui-layer-rim', // 加上边框
								area : [ '300px', '400px' ],
								title : '请选择参会人员',
								content : html
							});				
			    	  
			      });
				//查看党组织积分说明
				$('#queryDzzScoreInfo').click(function (){					
					var html ="";
					var typename="";
					var type="";//加分减分
					$.ajax({
						url : "${ctx}/life/organizeLifeQd/getPartyAssessmentInfo/1", 
						type : "get",
						dataType : "json",
						async : false,//同步  
						success : function(text) {
							typename=text.partyType;
							html +=  "<table class='e-table'><tr><td>积分内容</td><td>分值设置</td><td>类型</td></tr>"
							for (var i = 0; i < text.partyAssessmentInfoList.length; i++) {
								if(text.partyAssessmentInfoList[i].type=='1'){									
									type="加分";
					        	}else{
					        		type="减分";
					        	}																
								html+="<tr>"
								+ "<td  style='width:300px;text-align:left'>"+text.partyAssessmentInfoList[i].integralContent+"</td>"
								+ "<td style='width:470px;text-align:left'><span style='color:black'>"+text.partyAssessmentInfoList[i].remark+"</span></td>"
								+ "<td style='width:30px'><span style='color:black'>"+type+"</span></td>"
								+ "</tr>";		
								
							}
							html+="</table>"							
						}
					});

					layer.open({
								type : 1,
								skin : 'layui-layer-rim', // 加上边框
								area : [ '800px', '350px' ],
								title : '党组织积分信息化管理项目表('+typename+')',
								content : html
							});				
			    	  
			      });
				
				
				//查看党员积分说明
				$('#queryPersonScoreInfo').click(function (){					
					var html ="";
					var typename="";
					var type="";//加分减分
					$.ajax({
						url : "${ctx}/life/organizeLifeQd/getPartyAssessmentInfo/1", 
						type : "get",
						dataType : "json",
						async : false,//同步  
						success : function(text) {
							typename=text.partyType;
							html +=  "<table class='e-table'><tr><td>积分内容</td><td>分值设置</td><td>类型</td></tr>"
							for (var i = 0; i < text.personAssessmentInfoList.length; i++) {
								if(text.personAssessmentInfoList[i].type=='1'){									
									type="加分";
					        	}else{
					        		type="减分";
					        	}																
								html+="<tr>"
								+ "<td  style='width:300px;text-align:left'>"+text.personAssessmentInfoList[i].title+"</td>"
								+ "<td style='width:470px;text-align:left'><span style='color:black'>"+text.personAssessmentInfoList[i].content+"</span></td>"
								+ "<td style='width:30px'><span style='color:black'>"+type+"</span></td>"
								+ "</tr>";		
								
							}
							html+="</table>"							
						}
					});

					layer.open({
								type : 1,
								skin : 'layui-layer-rim', // 加上边框
								area : [ '800px', '350px' ],
								title : '党员积分信息化管理项目表('+typename+')',
								content : html
							});				
			    	  
			      });
			      
			            //刷卡录入事件  
				$('#cardAdd').click(function (){
					top.$("#_card_win").click();
					
					
			      });
				  //判断积分内容是否重复
			      function checkCf(){
			    	  var check=true;
			    	  
			    	  var partyScoreIds = [];
			    	  var personScoreIds = [];
			    	  var divs = $("#ceons").find("div[id^=lkj]");
			    	  var divs1 = $("#personS").find("div[id^=dyjs]");
			    	  $(divs).each(function(j, divs) {		  
			    		  partyScoreIds.push($("#partyscoreid"+j).val());
			    		});		
			    	  
			    	  var nary=partyScoreIds.sort(); 
			    	  for(var i=0;i<partyScoreIds.length;i++){ 
			    	  if (nary[i]==nary[i+1]){ 
			    	  alert("党组织积分内容重复"); 
			    	  check=false;
			    	  return false;
			    	  } else{
			    		  check=true;
			    	  }
			    	  } 
			    	  $(divs1).each(function(j, divs1) {	
			    		  personScoreIds.push($("#personscoreid"+j).val());  
			    	  });	
			    	  
			    	  var nary1=personScoreIds.sort(); 
			    	  for(var i=0;i<personScoreIds.length;i++){ 
			    	  if (nary1[i]==nary1[i+1]){ 
			    	  alert("党员积分内容重复"); 
			    	  check=false;
			    	  return false;
			    	  } else{
			    		  check=true;
			    	  }
			    	  } 
			    	  return check;
			      }
				    //结束登记
				    $('#jsdj').click(function (){		
				    	
				    	if(checkCf()){
				    		
				    		var organizeId="1";//党支部ID
					    	var organizeLifeId=$("#id").val();//组织生活ID
		                    //组装党组织积分明细		    	
					    	var partyScoreDetailList=new Array();                   
					    	var divs = $("#ceons").find("div[id^=lkj]");	    	    
				    		$(divs).each(function(j, divs) {		  
				    			
				    			var partyAssessmentInfoId=$("#partyscoreid"+j).val();
				    			var scoreMode=$("#scoreModeText"+j).val();
				    			var score=$("#dzzscore"+j).val();
				    			var defaultScore=$("#scoreNumber"+j).val();
				    			var upperScore=$("#upperLimitScore"+j).val();//上限分数
				    			var type=$("#dzztype"+j).val();//加分减分
				    			var year=$("#column24").find("option:selected").text();//年份
				    			var partyScoreDetai=createPartyScoreDetail(organizeId, organizeLifeId, partyAssessmentInfoId, scoreMode,defaultScore,score
				    		  			,upperScore,type,year);		    			
				    			partyScoreDetailList.push(partyScoreDetai);		    			
				    		});		    		
		    				    				    		
				    		//组装党员积分明细	
					    	var personScoreDetailList=new Array();	    	
					    	//一个积分项的所有人员
		                    var organizePersonDetailList=new Array();
					    	var divs = $("#personS").find("div[id^=dyjs]");	    	    
				    		$(divs).each(function(j, divs) {		  
				    			var personAssessmentInfoId=$("#personscoreid"+j).val();
				    			var scoreMode=$("#dyscoreModeText"+j).val();
				    			var score=$("#dyfz"+j).val();
				    			var defaultScore=$("#dyscoreNumber"+j).val();
				    			var upperScore=$("#dyupperLimitScore"+j).val();//上限分数
				    			var type=$("#dytype"+j).val();//加分减分
				    			var year=$("#column24").find("option:selected").text();//年份
				    			var personScoreDetail=createPersonScoreDetail(organizeId, organizeLifeId, personAssessmentInfoId, scoreMode,defaultScore,score
				    		  			,upperScore,type,year);		    			
				    			personScoreDetailList.push(personScoreDetail);
			                    var organizePersonDetailListInfo=new Array();
				    			$("#personInfo").find("tr").each(function(){		    			
					    			var personId=$(this).children("td").eq(1).children("input").eq(0).val();	
					    			var personName=$(this).children("td" ).eq(1).text();
					    			var sex=$(this).children("td" ).eq(2).text();
					    			var signMode=$(this).children("td" ).eq(3).text();
					    			var organizePersonDetail=createOrganizePersonDetail(organizeId, organizeLifeId, 
					    					score,score,personId,signMode,sex,$("#column24").find("option:selected").text(),
					    					personAssessmentInfoId,personName,type)		
					    					
					    			organizePersonDetailListInfo.push(organizePersonDetail);		    			
					    		});		    
				    			organizePersonDetailList.push(organizePersonDetailListInfo);	
				    		});	    		
				    		var sdperson="";
					    	$("#personInfo").find("tr").each(function(){	    			
					    		sdperson+=$(this).children("td" ).eq(1).text()+",";
				    		});		    
					    	  if (sdperson.length > 0) {
					    		  sdperson = sdperson.substr(0, sdperson.length - 1);
					    	    }		
				    	var organizeLife=createQd($("#id").val(),$("#personInfo tr").length,partyScoreDetailList,personScoreDetailList,
				    			organizePersonDetailList,sdperson,$("#column24").val());
				    	$.ajax({
							type : 'POST',	
							url : "${ctx}/life/organizeLifeQd/upqd",
							dataType : 'json',
							contentType : 'application/json',
							data : JSON.stringify(organizeLife),
							success : function(result) {		
								if(result.type == "success"){
								//	$("#inputForm").attr("action","${ctx}/life/organizeLifeQd/list");
									$("#inputForm").attr("action","${ctx}/life/organizeLifeQd/form");
									$("#inputForm").submit();
								} else {
									alert("签到失败！");
								}
							}
						});
				    	}
				    	
				    	
			 })      
			});
			function xg() {
				
				
				  var date = new Date();
				    var seperator1 = "-";
				    var seperator2 = ":";
				    var year = date.getFullYear();
				    var month = date.getMonth() + 1;
				    var strDate = date.getDate();
				    if (month >= 1 && month <= 9) {
				        month = "0" + month;
				    }
				    if (strDate >= 0 && strDate <= 9) {
				        strDate = "0" + strDate;
				    }
				    var currentdate = date.getHours() + seperator2 + date.getMinutes();
				
				var check=true;
				var personid=$("input[name='radioPersonId']:checked").val();
				var personName=$(".sds:checked").parent().next().children().text();
				var sex=$(".sds:checked").parent().next().next().children().text();
				if(personName == ''){
    				alert("请选择参会人员！");
    				check=false;
    			}			
				$("#personInfo").find("tr").each(function(){		    			
	    			var personId1=$(this).children("td").eq(1).children("input").eq(0).val();
	       			if(personid==personId1){
	    				alert("当前党员已签到，请重新选择！");
	    				check=false;
	    			}
	    		});		    
				if(check){
					layer.closeAll();			
					var sqscore=0;
					var shcore=0;
					var divs = $("#personS").find("div[id^=dyjs]");	    	    
		    		$(divs).each(function(j, divs) {		      			
		    			 score=$("#dyscoreNumber"+j).val();
		    			 defaultScore=$("#dyfz"+j).val();
		    			 sqscore=sqscore+score*1;
		    			 shcore=shcore+defaultScore*1;
		    		});		
		    		var itemSeq = 1 ;
					var trs = $("#personInfo").find("tr");
					var xuhao = trs.length;
					itemSeq++;
					
					$("#personInfo").append("<tr class='personInfo' id='"
									+ (xuhao + 1)
									+ "'>"
									+ "<td><span style='color:black'>"
									+ (xuhao + 1)
									+ "</span></td>"
									+ "<td>"+personName+"<input type='hidden' id='personId' value="+personid+" ></input></td>"
									+ "<td>"+sex+"</td>"
									+ "<td>手工录入<input type='hidden' id='signMode' value='1' ></input></td>"
									+ "<td>"+currentdate+"</td>"
									+ "<td style='text-align: center;'><button onclick='delPerson(this)' class='btn' data-toggle='modal' style='background: red; color: #FFF;'  data-target='#modal-del'>删除</button></td>"
									+ "</tr>");
				}		
			}

		  //删除方法
        function delPerson(obj) {
        	$(obj).parent().parent().remove();
        	
        	var trs = $("#personInfo").find("tr");
        	trs.each(function(k, value) {        		
        		// 重新排列序号
        		var spans = $(this).find("span");
        		for (var j = 0; j < spans.size(); j++) {
        			var span = spans[j];
        			$(span).text(k + 1);
        		}
        		// 设置TR的行ID
        		var trs = $(this).parent().find("tr");
        		$(trs).each(function(j, trs) {
        			$(this).prop("id", (j + 1));
        		});
        	});        
          }
		
	      function change(id,size){
	    	  if(id != null && id != ''){					
					 $.ajax({  
					        url: "${ctx}/life/organizeLifeQd/queryPartyAssessmentInfo/"+id,  
					        type: "get",  
					        dataType: "json",  
					        async: false,//同步  
					        success: function(text){  
					        	if(text.scoreMode=='1'){
					        		$("#scoreModeText"+size).val("固定"); 
					        		$("#dzzscore"+size).attr("readonly","readonly");
					        	}else{
					        		$("#scoreModeText"+size).val("自设"); 
					        		$("#dzzscore"+size).removeAttr("readonly");
					        	}
					        	//$("#scoreMode"+size).val(text.scoreMode); 					        	
					        	$("#scoreNumber"+size).val(text.scoreNumber); 
					        	$("#dzzscore"+size).val(text.scoreNumber); 					        	
					        	if(text.type=='1'){
					        		$("#typeText"+size).val("加分"); 
					        	}else{
					        		$("#typeText"+size).val("减分"); 
					        	}
					        	$("#dzztype"+size).val(text.type); 
					        	
					        	//$("#type"+size).val(text.type);
					        	$("#upperLimitScore"+size).val(text.upperLimitScore);
					        	$("#dzzsqcs"+size).val(text.applyCount);
					        }  
					    });  
				}	    	 
}
	      
	      function dychange(id,size){
	    	  if(id != null && id != ''){					
					 $.ajax({  
					        url: "${ctx}/life/organizeLifeQd/queryPersonAssessmentInfo/"+id,  
					        type: "get",  
					        dataType: "json",  
					        async: false,//同步  
					        success: function(text){  
					        	if(text.sourceType=='1'){
					        		$("#dyscoreModeText"+size).val("固定"); 
					        		$("#dyfz"+size).attr("readonly","readonly");
					        	}else{
					        		$("#dyscoreModeText"+size).val("自设"); 
					        		$("#dyfz"+size).removeAttr("readonly");
					        	}
					        	$("#dyscoreMode"+size).val(text.sourceType); 			//分值方式：固定，自设		        	
					        	$("#dyscoreNumber"+size).val(text.upperCount); //分/次
					        	$("#dyfz"+size).val(text.upperCount); 					        	
					        	if(text.type=='1'){
					        		$("#dytyText"+size).val("加分"); 
					        	}else{
					        		$("#dytyText"+size).val("减分"); 
					        	}
					        	$("#dytype"+size).val(text.type); 					        	
					        	$("#dyupperLimitScore"+size).val(text.upperScore);
					        	$("#dysqcs"+size).val(text.applyCount);
					        }  
					    });  
				}
	    	 
}
		    //创建党组织积分内容明细对象
		  	function createPartyScoreDetail(organizeId, organizeLifeId, partyAssessmentInfoId, scoreMode,defaultScore,score
		  			,upperScore,type,year) {
				var object = new Object();
				object.organizeId = organizeId;//党组织ID
				object.organizeLifeId = organizeLifeId;//组织生活id
				object.partyAssessmentInfoId = partyAssessmentInfoId;//积分id
				object.scoreMode = scoreMode;//分值方式
				object.defaultScore = defaultScore;//分值（默认分数）
				object.score = score;//积分
				object.upperScore = upperScore;
				object.type = type;//类型加分减分
				object.year = year;//年份

				return object;
			}
		    //创建党员积分内容明细对象
		  	function createPersonScoreDetail(organizeId, organizeLifeId, personAssessmentInfoId, scoreMode,defaultScore,score
		  			,upperScore,type,year) {
				var object = new Object();
				object.organizeId = organizeId;//党组织ID
				object.organizeLifeId = organizeLifeId;//组织生活id
				object.personAssessmentInfoId = personAssessmentInfoId;//积分id
				object.scoreMode = scoreMode;//分值方式
				object.defaultScore = defaultScore;//分值（默认分数）
				object.score = score;//积分
				object.upperScore = upperScore;
				object.type = type;//类型加分减分
				object.year = year;//年份

				return object;
			}
		    //创建党员申请积分明细对象
		  	function createOrganizePersonDetail(organizeId, organizeLifeId,applyScore,checkScore,personId
		  			,signMode,sex,column1,personAssessmentInfoId,column2,type) {
				var object = new Object();
				object.organizeId = organizeId;//党组织ID
				object.organizeLifeId = organizeLifeId;//组织生活id
				object.applyScore = applyScore;
				object.checkScore = checkScore;
				object.personId = personId;//参会人员ID
				object.signMode = signMode;//录入方式
				object.sex = sex;//性别
				object.column1 = column1;//年份
				object.personAssessmentInfoId = personAssessmentInfoId;//年份
				object.column2 = column2;
				object.type = type;
				return object;
			}
		    //创建签到总的对象
			function createQd(id,sdnum,partyScoreDetailList,personScoreDetailList,organizePersonDetailList,sdperson,column24) {
				var object = new Object();
				object.id = id;
				object.sdnum = sdnum;//实到人数
				object.partyScoreDetailList = partyScoreDetailList;
				object.personScoreDetailList = personScoreDetailList;
				object.organizePersonDetailList = organizePersonDetailList;
				object.sdperson = sdperson;
				object.column24 = column24;
				return object;
		    }
			function checknum(obj)
			{   if(/^\d+\.?\d{0,1}$/.test(obj.value)){
			       obj.value = obj.value;
			    }else{
			   obj.value = obj.value.substring(0,obj.value.length-1);
			}
			   
			}

			
			
			 //手工录入事件  
			$('#dzzQueryScoreInfo').click(function (){
				
				var html ="";
				$.ajax({
					url : "${ctx}/life/organizeLifeJh/getPersonByOrgid",
					type : "get",
					dataType : "json",
					async : false,//同步  
					success : function(text) {
						html +=  "<div style='text-align:left'>"
						+"<input id='xgBtn1' onclick='xg()' class='btn libts' style='background: red; color: #FFF;' type='button' value='确认'/></div>"
						+"<div class='tab-pane' style='padding: 20px 40px;'><table class=''>"
						for (var i = 0; i < text.length; i++) {
							
							var sex="";
							if(text[i].sex=='1'){
								sex="男";
							}else if(text[i].sex=='2'){
								sex="女";									
							}else{
								sex="男";
							}
							html+="<tr id='"+ (i + 1)+ "'>"
											+ "<td style='width:30px'><input type='radio' class='sds' id='radioPersonId' name='radioPersonId' value="+text[i].userId+"></td>"
											+ "<td style='width:100px'><span style='color:black'>"+text[i].userName+"</span></td>"
											+ "<td style='width:100px'><span style='color:black'>"+sex+"</span></td>"
											+ "</tr>";
											}
						html+="</table></div>"
						
					}
				});

				layer.open({
							type : 1,
							skin : 'layui-layer-rim', // 加上边框
							area : [ '200px', '300px' ],
							title : '请选择参会人员',
							content : html
						});				
		    	  
		      })
					
</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a>组织生活修改签到</a></li>
	</ul>
<form:form id="inputForm" modelAttribute="organizeLife" action="${ctx}/life/organizeLifeQd/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>		
<div class="container">
		<input type="hidden" id="pid"></input>		
			<div class="e-main" style='padding-bottom:60px;'>
				<div class="mian-box-content pb1">
					<div class="row margin-b10">
						<div class="col-xs-12">
							<div class="row-space">
								<div class="e-box float-e-margins  pb15">
									<div class="e-box-title">
										<h2>组织生活签到详情</h2>										
									</div>
									<div class="control-group">
									<div class="e-form pl15 form-item w-100per">
										<div class="col-md-1 tr"><span class="form-item-name w-5xl lh32">活动名称:</span>
										</div>	
									<div class="col-md-2">
										<form:input path="lifename" htmlEscape="false" style="width:800px"  readonly="true" class="input-xlarge required" value="${organizeLife.lifename}"/>
											<input type="hidden" id="organizeLifeId" val="${organizeLife.id}" ></input>
											</div>
									</div>
</div>
 <div class="control-group">
									<div class="e-form pl15 form-item w-100per">
										<div class="col-md-1 tr"><span class="form-item-name w-5xl lh32">年份：</span>
										</div>
											<div class="col-md-2">
											<form:select path="column24" class="input-medium">
												<form:options items="${assessmentTimeList}"
													itemLabel="year" itemValue="id" htmlEscape="false" />
											</form:select>				
										</div>
										<div class="col-md-1 ml20 tr"><span class="form-item-name w-5xl lh32">计划时间:</span>
										
										</div>
										<input name="jhtime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate " value="<fmt:formatDate value="${organizeLife.jhtime}" pattern="yyyy-MM-dd HH:mm"/>"/>
										
									</div>
									</div>

								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="mian-box-content pt1">
					<div class="row margin-b10">
						<div class="col-xs-12">
							<div class="row-space">
								<div class="e-box float-e-margins  pb15">
									<div class="e-box-title">
										<h2>党组织积分内容</h2>
										<div class="e-box-toolbar" style="float: left;">

											<div class="btn-group">
												<button class="btn" data-toggle="modal" id="lbtns" style='background: red; color: #FFF;'   data-target="#modal-del">增加</button>
											</div>
										</div>
										<div class="e-box-toolbar">

											<div class="btn-group">
												<button class="btn" id="queryDzzScoreInfo" data-toggle="modal" data-target="#modal-del">查看积分说明</button>
											</div>
										</div>

									</div>
																		
									<div id="ceons">
									<c:forEach var='e' items='${partyScoreDetailList}' varStatus='i'>
										<div id="lkj${ i.index}" class="lkj">																					
										<div class="e-form pl15 form-item w-100per cler pt10 pb10">
											<div class="col-md-1 tr"><span class="form-item-name w-5xl lh32">积分内容</span>
											</div>
											<div class="col-md-9">
														<select id="partyscoreid${ i.index}"
															onchange="change(this.options[this.options.selectedIndex].value,${ i.index});"
															class="form-item-input w-100xl">
															<c:forEach var='d' items='${partyAssessmentInfoList}'>
																<c:choose>
																	<c:when test="${d.id==e.partyAssessmentInfoId}">
																		<option selected="selected" value='${d.id }'>${d.integralContent }</option>
																	</c:when>
																	<c:otherwise>
																		<option value='${d.id }'>${d.integralContent }</option>
																	</c:otherwise>
																</c:choose>
															</c:forEach>
														</select>
													</div>
										</div>
										<div class="form-item e-form w-100per pl15 cler divGroup">
											<div class="col-md-1 tr"><span class="form-item-name w-5xl lh32">赋分方式</span>
											</div>
											<div class="col-md-1">
											<input id="scoreModeText${ i.index}" type="text"  readonly="readonly" style="width:50px">
											</div>											
											<div class="col-md-2 tr"><span class="form-item-name w-5xl lh32">上限分值/次</span>
											</div>
											<div class="col-md-1 ">
												<input id="scoreNumber${ i.index}" type="text"  readonly="readonly" style="width:50px">
											</div>
											<div class="col-md-2 tr"><span class="form-item-name w-5xl lh32">申请积分<span style='color: red;font-size:50%;' >★</span></span>
											</div>
											<div class="col-md-1 ">
												<input id="dzzscore${ i.index}" type="text" onkeyup="checknum(this);" readonly="readonly"  style="width:50px">
											</div>
										</div>
										<div class="form-item e-form w-100per pl15 cler divGroup">
											<div class="col-md-1 tr"><span class="form-item-name w-5xl lh32">类型 </span>
											</div>
											<div class="col-md-1 ">
												<input id="typeText${ i.index}" type="text"  readonly="readonly" style="width:50px">
												<input type="hidden" name="dzztype0" id="dzztype0"> 
											</div>
											<div class="col-md-2 tr"><span class="form-item-name w-5xl lh32">上限分值 </span>
											</div>
											<div class="col-md-1 ">
											<input id="upperLimitScore${ i.index}" type="text"  readonly="readonly" style="width:50px">
											</div>
											<div class="col-md-2 tr"><span class="form-item-name w-5xl lh32">已申请次数</span>
											</div>
											<div class="col-md-1 ">
											<input id="dzzsqcs${ i.index}" type="text" readonly="readonly" style="width:50px">
											</div>
											<div class="col-md-2 tr">
												<div class="btn-group">
													<button class="btn shanc" data-toggle="modal" style="background: red; color: #FFF;"  data-target="#modal-del">删除</button>
												</div>
											</div>
										</div>
										<hr style="height:1px;border:none;border-top:1px  #555555;" />
									</div>
									</c:forEach>
									</div>
								    
								</div>

							</div>
						</div>
					</div>
				</div>

				<div class="mian-box-content pt1">
					<div class="row margin-b10">
						<div class="col-xs-12">
							<div class="row-space">
								<div class="e-box float-e-margins  pb15">
									<div class="e-box-title">
										<h2>党员积分内容</h2>
										<div class="e-box-toolbar" style="float: left;">

											<div class="btn-group">
												<button class="btn" id="libt" data-toggle="modal" style='background: red; color: #FFF;'   data-target="#modal-del">增加</button>
											</div>
										</div>
										<div class="e-box-toolbar">
											<div class="btn-group">
												<button class="btn" id="queryPersonScoreInfo" data-toggle="modal" data-target="#modal-del">查看积分说明</button>
											</div>
										</div>

									</div>
									<div id="personS">
									<c:forEach var='e' items='${personScoreDetailList}' varStatus='i'>
										<div id="dyjs${ i.index}" class="dyjs">
									<div class="e-form pl15 form-item w-100per cler pt10 pb10">
										<div class="col-md-1 tr"><span class="form-item-name w-5xl lh32">积分内容</span>
										</div>
										<div class="col-md-9">
											<select id="personscoreid${ i.index}" onchange="dychange(this.options[this.options.selectedIndex].value,0);" class="form-item-input w-100xl">
														<c:forEach var='d' items='${personAssessmentInfoList}'>															
																	
															<c:choose>
																	<c:when test="${d.id==e.personAssessmentInfoId}">
																	<option selected="selected"  value='${d.id }'>${d.title }</option>
																	</c:when>
																	<c:otherwise>
																		<option value='${d.id }'>${d.title }</option>
																	</c:otherwise>
																</c:choose>														
														</c:forEach>
													</select> 
										</div>

									</div>
										<div class="form-item e-form w-100per pl15 cler divGroup">
											<div class="col-md-1 tr"><span class="form-item-name w-5xl lh32">赋分方式</span>
											</div>
											<div class="col-md-1">
											<input id="dyscoreModeText${ i.index}" type="text"  readonly="readonly" style="width:50px">
											</div>											
											<div class="col-md-2 tr"><span class="form-item-name w-5xl lh32">上限分值/次</span>
											</div>
											<div class="col-md-1 ">
												<input id="dyscoreNumber${ i.index}" type="text"  readonly="readonly" style="width:50px">
											</div>
											<div class="col-md-2 tr"><span class="form-item-name w-5xl lh32">申请积分<span style='color: red;font-size:50%;' >★</span></span>
											</div>
											<div class="col-md-1 ">
												<input id="dyfz${ i.index}" type="text" onkeyup="checknum(this);" readonly="readonly"  style="width:50px">
											</div>
										</div>
										<div class="form-item e-form w-100per pl15 cler divGroup">
											<div class="col-md-1 tr"><span class="form-item-name w-5xl lh32">类型 </span>
											</div>
											<div class="col-md-1 ">
												<input id="dytyText${ i.index}" type="text"  readonly="readonly" style="width:50px">
												<input type="hidden" id="dytype${ i.index}"> 
											</div>
											<div class="col-md-2 tr"><span class="form-item-name w-5xl lh32">上限分值 </span>
											</div>
											<div class="col-md-1 ">
											<input id="dyupperLimitScore${ i.index}" type="text"  readonly="readonly" style="width:50px">
											</div>
											<div class="col-md-2 tr"><span class="form-item-name w-5xl lh32">已申请次数</span>
											</div>
											<div class="col-md-1 ">
											<input id="dysqcs${ i.index}" type="text" readonly="readonly" style="width:50px">
											</div>
													<div class="col-md-2 tr">
											<div class="btn-group">
												<button class="btn libts" data-toggle="modal" style="background: red; color: #FFF;"  data-target="#modal-del">删除</button>
											</div>
										</div>
									</div>
									<hr style="height:1px;border:none;border-top:1px  #555555;" />
									</div>
									</c:forEach>
						         </div>
								</div>
							</div>
						</div>
					</div>
				</div>

				<div class="mian-box-content pt1">
					<div class="row margin-b10">
						<div class="col-xs-12">
							<div class="row-space">
								<div class="e-box float-e-margins  pb15">
									<div class="e-box-title">
										<h2>党员签到明细</h2>

										<div class="e-box-toolbar">
											<div class="btn-group">
												<button class="btn" id="cardAdd" data-toggle="modal" data-target="#modal-del">刷卡录入</button>
											</div>
										</div>
										<div class="e-box-toolbar">
											<div class="btn-group">
												<button class="btn"  id="sgAdd" data-toggle="modal" data-target="#modal-del">手工录入</button>
											</div>
										</div>
										<div class="e-box-toolbar">
											<div class="btn-group">
												<button class="btn" id="jsdj"  data-toggle="modal" data-target="#modal-del">结束登记</button>
												<input type="hidden" id="_card_child"/>
											</div>
										</div>

									</div>
									<div class="e-box-content p-xs">
										<div id="tab8-2" class="tab-pane">
											<table class="e-table ">
												<thead>
													<tr>
													    <th>序号</th>
														<th>姓名</th>
														<th>性别</th>
														<th class="tc">记录方式</th>
														<th>签到时间</th>
														<th class="tc">操作</th>

													</tr>
												</thead>
												<tbody id="personInfo">
													<c:forEach var='e' items='${organizePersonDetailList}' varStatus='i'>
													
													<tr class='personInfo' id="${ i.index+1}">
													<td><span style='color:black'>${ i.index+1}</span></td>
							<td>${e.column2}<input type='hidden' id='personId' value='${e.personId}' ></input></td>
							<td>${e.sex}</td>
							<td>${e.signMode}<input type='hidden' id='signMode' value='${e.signMode}' ></input></td>
							<td><fmt:formatDate value="${e.createDate}" pattern="HH:mm"/></td>
							<td style='text-align: center;'>
							<button onclick='delPerson(this)' class='btn' data-toggle='modal' 
							style='background: red; color: #FFF;'  data-target='#modal-del'>删除</button>
							</td>
							</tr>
													
													</c:forEach>

												</tbody>
											
											</table>
										</div>

									</div>

								</div>
							</div>
						</div>
					</div>

				</div>

			</div>
		</div>
		</form:form>
		
</body>
</html>